<div class="jdl-metadata-container">
    <div class="card shadow-sm mb-4">
        <div class="card-header bg-white d-flex justify-content-between align-items-center">
            <h2 class="mb-0">
                <fa-icon [icon]="'object-group'" class="text-primary mr-2"></fa-icon>
                <span>设计实体</span>
            </h2>
            <div>
                <button class="btn btn-outline-secondary mr-2" (click)="loadAll()">
                    <fa-icon [icon]="'sync'" [spin]="jdlRefresh" class="mr-1"></fa-icon>
                    <span>刷新</span>
                </button>
                <a href="jdl-studio/" class="btn btn-primary jh-create-entity create-jdl-metadata">
                    <fa-icon [icon]="'bolt'" class="mr-1"></fa-icon>
                    <span>创建新的JDL模型</span>
                </a>
            </div>
        </div>
        <div class="card-body">
            <jhi-alert></jhi-alert>
            <p class="text-muted">
                <i>JDL Studio是一个图形化工具，用于使用<a href="https://www.jhipster.tech/jdl/" target="_blank" rel="noopener noreferrer">JHipster领域语言(JDL)</a>设计您的实体。</i>
            </p>
            <div class="table-responsive" *ngIf="jdlMetadata">
                <table class="table table-hover border" aria-describedby="JDL更新">
                    <thead class="thead-light">
                    <tr jhiSort jhiSort [(predicate)]="predicate" [(ascending)]="ascending" [callback]="loadAll.bind(this)">
                        <th scope="col" jhiSortBy="name" class="align-middle"><span>名称</span> <fa-icon [icon]="getSortingIcon('name')"></fa-icon></th>
                        <th scope="col" jhiSortBy="updatedDate" class="align-middle"><span>最后更新</span> <fa-icon [icon]="getSortingIcon('updatedDate')"></fa-icon></th>
                        <th scope="col" class="text-center align-middle"><span>操作</span></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr *ngIf="jdlMetadata.length === 0">
                        <td colspan="4" class="text-center py-4">
                            <span class="text-muted"><i>尚未创建JDL模型</i></span>
                        </td>
                    </tr>
                    <tr *ngFor="let jdlMetadata of jdlMetadata ;trackBy: trackId">
                        <td class="align-middle">{{jdlMetadata.name}}</td>
                        <td class="align-middle">{{jdlMetadata.updatedDate | date:'medium'}}</td>
                        <td class="text-center">
                            <div class="btn-group">
                                <a href="jdl-studio/#!/view/{{jdlMetadata.id}}" class="btn btn-outline-info btn-sm">
                                    <fa-icon [icon]="'eye'"></fa-icon>
                                    <span class="hidden-md-down ml-1">打开</span>
                                </a>
                                <button type="submit"
                                        [routerLink]="['/design-entities-apply/'+ jdlMetadata.id]"
                                        replaceUrl="true"
                                        class="btn btn-outline-primary btn-sm">
                                    <fa-icon [icon]="'check'"></fa-icon>
                                    <span class="hidden-md-down ml-1">应用</span>
                                </button>
                                <button type="submit"
                                        [routerLink]="['/design-entities-delete/'+ jdlMetadata.id]"
                                        replaceUrl="true"
                                        class="btn btn-outline-danger btn-sm">
                                    <fa-icon [icon]="'trash'"></fa-icon>
                                    <span class="hidden-md-down ml-1">删除</span>
                                </button>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<style>
    .jdl-metadata-container {
        padding: 15px 0;
    }
    .card-header {
        border-bottom: 1px solid rgba(0,0,0,0.125);
    }
    .btn-group .btn {
        margin-right: 5px;
    }
    .btn-group .btn:last-child {
        margin-right: 0;
    }
</style>
